package com.jspgou.cms.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jspgou.common.hibernate3.Updater;
import com.jspgou.common.page.Pagination;
import com.jspgou.cms.dao.ShopTuijianDao;
import com.jspgou.cms.entity.ShopTuijian;
import com.jspgou.cms.manager.ShopTuijianMng;

@Service
@Transactional
public class ShopTuijianMngImpl implements ShopTuijianMng {
	@Transactional(readOnly = true)
	public Pagination getPage(int pageNo, int pageSize) {
		Pagination page = dao.getPage(pageNo, pageSize);
		return page;
	}

	@Transactional(readOnly = true)
	public ShopTuijian findById(Long id) {
		ShopTuijian entity = dao.findById(id);
		return entity;
	}

	public ShopTuijian save(ShopTuijian bean) {
		dao.save(bean);
		return bean;
	}

	public ShopTuijian update(ShopTuijian bean) {
		Updater<ShopTuijian> updater = new Updater<ShopTuijian>(bean);
		ShopTuijian entity = dao.updateByUpdater(updater);
		return entity;
	}

	public ShopTuijian deleteById(Long id) {
		ShopTuijian bean = dao.deleteById(id);
		return bean;
	}
	
	public ShopTuijian[] deleteByIds(Long[] ids) {
		ShopTuijian[] beans = new ShopTuijian[ids.length];
		for (int i = 0,len = ids.length; i < len; i++) {
			beans[i] = deleteById(ids[i]);
		}
		return beans;
	}

	private ShopTuijianDao dao;

	@Autowired
	public void setDao(ShopTuijianDao dao) {
		this.dao = dao;
	}

	public List<ShopTuijian> list() {
		return dao.list();
	}
}